package java0819;

public class ThreadDemo29 {
    static class Result{
        public int sum = 0;
        public Object locker = new Object();
    }
    public static void main(String[] args) throws InterruptedException {
        Result result = new Result();
        Thread t = new Thread(){
            @Override
            public void run() {
                int sum = 0;
                for (int i = 0; i <= 1000; i++){
                    sum += i;
                }
                result.sum = sum;
                synchronized (result.locker) {
                    result.locker.notify();
                }

            }
        };
        t.start();

        synchronized (result.locker) {
            while (result.sum == 0){

                    result.locker.wait();
            }
        }

        System.out.println(result.sum);
    }
}
